import { Layout, Menu } from "antd";
import {
  HomeOutlined,
  UserOutlined,
  SettingOutlined,
  LogoutOutlined,
  IdcardOutlined,
  EditOutlined,
  UserAddOutlined,
  ProjectOutlined
} from "@ant-design/icons";
import type { MenuProps } from "antd";
import { signOut } from "next-auth/react";
import Link from "next/link";
import React from "react";

type MenuItem = Required<MenuProps>["items"][number];

const home: MenuItem = {
  label: (
    <Link href="/home">
      <a>首页</a>
    </Link>
  ),
  key: "home",
  icon: <HomeOutlined />,
};

const profile: MenuItem = {
  label: (
    <Link href="/profile">
      <a>个人信息</a>
    </Link>
  ),
  key: "profile",
  icon: <IdcardOutlined />,
};

const signout: MenuItem = {
  label: "退出",
  danger: true,
  key: "signout",
  icon: <LogoutOutlined />,
  onClick: () => {
    signOut();
  },
};

const setting: MenuItem = {
  label: "设置",
  key: "setting",
  icon: <SettingOutlined />,
  children: [profile, signout],
};

const addPerson: MenuItem = {
  label: (
    <Link href="/person/add">
      <a>添加人员</a>
    </Link>
  ),
  key: "add_person",
  icon: <UserAddOutlined />,
};

const modifyPerson: MenuItem = {
  label: (
    <Link href="/person/modify">
      <a>修改人员信息</a>
    </Link>
  ),
  key: "modify_person",
  icon: <EditOutlined />,
};

const personManagement: MenuItem = {
  label: "人员管理",
  key: "person_management",
  icon: <UserOutlined />,
  children: [addPerson, modifyPerson],
};

const activity: MenuItem = {
  label: '事件管理',
  key: "activity",
  children:[],
  icon:<ProjectOutlined />
};

export function getItemsMap(): Map<string, MenuItem> {
  const allItems: MenuItem[] = [home, setting, personManagement, activity];
  let allItemsMap = new Map<string, MenuItem>();
  allItems.forEach((element) => {
    allItemsMap.set(element!.key, element);
  });
  return allItemsMap;
}
export function getAllGroupItemsName(): Map<string, Array<string>> {
  let allItemsName = new Map<string, Array<string>>();
  allItemsName.set("setting", ["profile", "signout"]);
  allItemsName.set("person_management", ["add_person", "modify_person"]);
  allItemsName.set("house_unit_management", ["add_house", "modify_house"]);
  allItemsName.set("activity", ["add_house", "modify_house"]);
  return allItemsName;
}
